package leo.game.ui
{
	import flash.display.MovieClip;
	import flash.display.SimpleButton;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	
	import ghostcat.util.easing.TweenUtil;
	
	import leo.data.GameModel;
	import leo.manager.McMannager;

	/**
	 * 过关界面 
	 * @author leo
	 * 
	 */	
	public class UIWin extends Sprite
	{
		private static var _instance :UIWin = null;
		private var btnOK :SimpleButton;
		public function UIWin() 
		{
			super();
			
			var name :String = "UI_Pass";
			var mc :MovieClip  = McMannager.instance.getMCByName(name);
			this.addChild(mc);
			
			this.btnOK = mc.btnOK;
			this.btnOK.addEventListener(MouseEvent.CLICK,clickHandler);
		}
		
		
		/**
		 * 显示缓动 
		 * @param duration 时间
		 * @param tx
		 * @param ty
		 * 
		 */		
		public function showUIWin(duration :int ,tx :int,ty :int):void
		{
			TweenUtil.to(this,duration,{x :tx,y:ty});
		}
		

		public static function get instance():UIWin
		{
			if(_instance == null)
			{
				_instance = new UIWin();
			}
			return _instance;
		}
		
		private function clickHandler(event :MouseEvent):void
		{
			this.showUIWin(1000,-250,300);

			
			GameModel.instance.curLevel++;
			var level :int = GameModel.instance.curLevel;
			UILevel.instance.changeLevel(level);
			UILevel.instance.showUILevel(1000,300,300);
		}

	}
}